package be.bonamis.timesheet.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import be.bonamis.timesheet.dto.PersonDTO;
import be.bonamis.timesheet.dto.PrestationTypeDTO;
import be.bonamis.timesheet.dto.ProjectDTO;
import be.bonamis.timesheet.util.Import;

@Service
public class CreateDb {

	protected static final String PERSON_NAME = "Jonard";
	protected static final String PERSON_INITIALS = "JJ";
	protected static final String PROJECT_NAME = "test01";
	protected static final String TYPE_DESCRIPTION = "Rédiger un courier";

	@Resource
    private PersonService personService;
	
	@Resource
    private ProjectService projectService;
	
	@Resource
    private PrestationTypeService prestationTypeService;
	
	public void insertValues(){
		PersonDTO personDTO = new PersonDTO();
		personDTO.setFirstName("Florent");
		personDTO.setLastName("Bonamis");
		personDTO.setInitials("FB");
		personService.create(personDTO);
		personDTO = new PersonDTO();
		personDTO.setFirstName("Jérôme");
		personDTO.setLastName(PERSON_NAME);
		personDTO.setInitials(PERSON_INITIALS);
		personService.create(personDTO);		
		
		List<ProjectDTO> list =	Import.importFromFile("us_states.xls");
		for (ProjectDTO projectDTO : list) {
			projectService.create(projectDTO);
		}
		
		PrestationTypeDTO prestationTypeDTO = new PrestationTypeDTO();
		prestationTypeDTO.setDefaultTime(15);
		prestationTypeDTO.setDescription(TYPE_DESCRIPTION);
		prestationTypeService.create(prestationTypeDTO);
		prestationTypeDTO = new PrestationTypeDTO();
		prestationTypeDTO.setDefaultTime(20);
		prestationTypeDTO.setDescription("Passer un coup de téléphone");
		prestationTypeService.create(prestationTypeDTO);
		
		
		
	}

}
